# -*- coding: UTF-8 -*-

from odoorpc2 import RPC

base_url = 'http://192.168.56.111:8069'
base_url = 'http://localhost:8069'
timeout = 50000

dbname = 'T2'
username = 'admin'
password = '123456'

rpc = RPC(base_url, timeout, dbname)


def test_login():
    print('test_login--------------', dbname, username,  password)
    res = rpc.login(username,  password)
    print('login=', res)

    res = rpc.web.session.authenticate(
        db=dbname, login=username, password=password)
    print('web.session.authenticate=', res)

    res = rpc.web.session.get_session_info()
    print('web.session.get_session_info=', res)

    res = rpc.web.session.check()
    print('web.session.check=', res)

    res = rpc.web.session.destroy()
    print('web.session.destroy=', res)


def test_login_destroy_check():
    print('test_login_destroy_check--------------')
    res = rpc.login(username,  password)
    print('login=', res)

    res = rpc.web.session.get_session_info()
    print('web.session.get_session_info=', res)

    res = rpc.web.session.check()
    print('web.session.check=', res)

    res = rpc.web.session.destroy()
    print('web.session.destroy=', res)

    res = rpc.web.session.check()
    print('web.session.check=', res)


def test_login_destroy_session():
    print('test_login_destroy_session--------------')
    res = rpc.login(username,  password)
    print('login=', res)

    res = rpc.web.session.get_session_info()
    print('web.session.get_session_info=', res)

    res = rpc.web.session.check()
    print('web.session.check=', res)

    res = rpc.web.session.destroy()
    print('web.session.destroy=', res)

    res = rpc.web.session.get_session_info()
    print('web.session.get_session_info=', res)


def test():

    test_login()
    # test_login_destroy_check()
    # test_login_destroy_session()


test()
